﻿using AutoMapper;
using B.S.BasicData.Api.Read.Application.Command.RoleMenu;
using B.S.BasicData.Api.Read.DTO;
using B.S.BasicData.Domian.Entities.RBAC;
using B.S.BasicData.ErrorCode;
using B.S.BasicData.Infrastructure.Interface;
using MediatR;

namespace B.S.BasicData.Api.Read.Application.Handler.RoleMenu
{
    public class RoleMenuHandler : IRequestHandler<RoleMenuCommand, ApiResult<List<RoleModel>>>
    {
        private readonly IBaseRepository<RoleModel> roleRepo;
        private readonly IMapper mapper;

        public RoleMenuHandler(IBaseRepository<RoleModel>roleRepo,IMapper mapper)
        {
            this.roleRepo = roleRepo;
            this.mapper = mapper;
        }
        public Task<ApiResult<List<RoleModel>>> Handle(RoleMenuCommand request, CancellationToken cancellationToken)
        {
           var res=new ApiResult<List<RoleModel>>();
            var role = roleRepo.GetAll().ToList();
            res.Message = "查询角色成功";
            res.Code=ApiEnum.Ok;
            res.Data =role;
            return Task.FromResult(res);
        }

        
    }
}
